#ifndef _ITEMDB_H_
#define _ITEMDB_H_

#include "odbcquery.h"
#include "ISProto.h"
#include "trademgr.h"
#include "mailmgr.h"
#include <vector>
#include <sdhlp/singleton.h>

using namespace std;

class CItemDB //: public CODBCQuery
{
public:
    CItemDB();
    virtual ~CItemDB();

    DECLARE_SINGLETON(CItemDB)

    bool Init();

    bool GetRolePKG(UINT32 dwTransID, UINT32 dwRoleID);

    bool CreateItem(UINT32 dwTransID, UINT32 dwRoleID, 
        const ::google::protobuf::RepeatedPtrField<ItemInfo> & pstItemInfo
        );

    bool UseItem(UINT32 dwTransID, UINT32 dwRoleID, 
        const ::google::protobuf::RepeatedPtrField<ItemBaseInfo> & pstItemsBaseInfo
        );

    bool ComplexOpt(UINT32 dwTransID, UINT32 dwRoleID, 
        const ::google::protobuf::RepeatedPtrField<ItemInfo> & pstCreateItemInfo, 
        const ::google::protobuf::RepeatedPtrField<ItemBaseInfo> & pstUseItemsBaseInfo
        );

    bool ChangeItemPos(UINT32 dwTransID, UINT32 dwRoleID, 
        const ::google::protobuf::RepeatedPtrField<ChangePosInfo> & pstChangeInfos
        );

    bool TradeItem(UINT32 dwTransID, STTRADERECORD* pstRecord);

    bool ConfirmTrade(UINT32 dwTransID, UINT32 dwRoleID, UINT32 dwTradeID);

    bool SendMail(UINT32 dwTransID, STMAILRECORD* pstMailRecord);

    bool RecvMail(UINT32 dwTransID, STMAILRECORD* pstMailRecord);

    bool RoleMail(UINT32 dwTransID, UINT32 dwRoleID);

    bool AddQuantity(UINT32 dwTransID, UINT32 dwRoleID, const ItemBaseInfo & item, int nCount);
};

#endif
